package main

import "fmt"

func printMap(cityMap map[string]string) {
	//cityMap 是一个引用传递
	for k, v := range cityMap {
		fmt.Println("k=", k)
		fmt.Println("v=", v)
	}
}

func changeVal(cityMap map[string]string) {
	cityMap["england"] = "London"
}

func main() {

	cityMap := make(map[string]string)

	//添加
	cityMap["china"] = "Beijing"
	cityMap["japan"] = "Tokyo"
	cityMap["usa"] = "NewYork"

	changeVal(cityMap)
	//遍历
	// for key, val := range cityMap {
	// 	fmt.Println("key = ", key)
	// 	fmt.Println("val = ", val)
	// }

	printMap(cityMap)

	//删除
	delete(cityMap, "china")

	//修改
	cityMap["usa"] = "Dc"

	fmt.Println("-----------")

	//遍历
	for key, val := range cityMap {
		fmt.Println("key = ", key)
		fmt.Println("val = ", val)
	}
}
